<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lmpop.trade.ti_teamorder.Ti_teamorderInfo"%>
<%@ page import="com.lmpop.trade.tb_returngoods.Tb_returngoodsInfo"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	String cust_id = "";
	if(session.getAttribute("session_cust_id") != null){
		cust_id=session.getAttribute("session_cust_id").toString();
	}
	
	String user_id = "";	
	if( session.getAttribute("session_user_id") != null ){
		user_id = session.getAttribute("session_user_id").toString();
	}
	
	String order_id = "";
	if(request.getParameter("order")!=null){
		order_id = request.getParameter("order");
	}
	
	String returnstate = "";
	if(request.getParameter("state")!=null){
		returnstate = request.getParameter("state");
	}
	
	Hashtable map = new Hashtable();
	Ti_teamorderInfo ti_teamorderInfo = new Ti_teamorderInfo();
	
	List list = ti_teamorderInfo.getListByPk(order_id);
	
	Hashtable inmap = (Hashtable)list.get(0);
	String info = inmap.get("info_id").toString();
  	String price = inmap.get("price").toString();
  	String title = "";
  	if(inmap.get("title") == null || "".equals(inmap.get("title").toString())){
  		%>
  			<script type="text/javascript">
				alert("您所找的商品已经下架");
			</script>
  		<%
  	}else{
  		title = inmap.get("title").toString();
  	}
  	String num = inmap.get("num").toString();

  	Tb_returngoodsInfo tb_returngoodsInfo = new Tb_returngoodsInfo();
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>团购首页</title>
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<meta name="application-name" content="徽诚网－每天团购一次，精品生活" />
		<meta name="msapplication-navbutton-color" content="#C3E9F6" />
		<meta name="msapplication-window"
			content="width=device-width;height=device-height" />
		<meta name="msapplication-tooltip" content="徽诚网－每天团购一次，精品生活" />
		<meta name="msapplication-task"
			content="name=今日团购;action-uri=/;icon-uri=/favicon.ico?v=3" />

		<link rel="stylesheet" href="/templets/html/css/teambuy_new.css">
		<link rel="stylesheet" href="/templets/html/css/tuangou_index.css" />
		
		<link href="/templets/html/css/bottom.css" rel="stylesheet" />
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Tb_returngoodsInfo.js'></script> 
		<meta name="description" />
		<meta name="keywords" />
<script language="javascript">
function chance(){
	var v = document.all.reason.value;
	var no = document.getElementById("returnteamno").value;
	if(no==null||no==''){
		alert("请输入退货数量");
		document.getElementById("returnteamno").focus();
		return false;
	}else if(v==null||v==''){
		alert("请输入退货原因");
		return false;
	}else{
		return window.addreturn.submit();
	}
}
function totalmaney(v){
	document.getElementById("team_tile").value = document.getElementById("title").innerHTML;
	var no = document.getElementById("returnteamno").value;
	var price = document.getElementById("money").value;
	document.getElementById("price").value = price;
	var num = <%=num%>;
	var countno;
	Tb_returngoodsInfo.getCountReturnNo(v,function(data){
	
		cnum = num - data;
		if(isNaN(no)){
			alert("请输入数字");
			document.getElementById("returnteamno").focus();
			document.getElementById("returnteamno").value = "";
			return false;
		}else if(no > num){
			alert("您输入的退货额大于您的购买额，请重新输入");
			document.getElementById("returnteamno").focus();
			document.getElementById("returnteamno").value = "";
			return false;
		}else if(no != "" && no > cnum){
			alert("您的退货额大于您所剩的商品总额");
			document.getElementById("returnteamno").focus();
			document.getElementById("returnteamno").value = "";
			return false;
		}else if(no > cnum){
		 	alert("您的退货额大于您所剩的商品总额，请重新输入");
		 	document.getElementById("returnteamno").focus();
			document.getElementById("returnteamno").value = "";
		 }else{
			var totalmoney = no * price;
			document.getElementById("totalprice").value=totalmoney;
			document.getElementById("totalmoney").value=totalmoney;
			return true;
		}
		 
	});
}

</script>
  </head>
  <jsp:include page="/templets/html/teambuy/teamtop.jsp" flush="true"></jsp:include>
  <body class="bg-alt" onLoad="show_student163_time();">
  <form action="/doTradeReg.do" name="addreturn" method="post">
 
  	<div id="mainbox">

			<div id="content" class="content5">
			<div class="content6_width">
				<div class="f-input">
					<span><strong></strong>订单编号</span>
					<label id="order_id" ><%=order_id%></label>
				</div>
				<div class="f-input">
					<span><strong>*</strong>退货商品</span>
					<label id="title" ><%=title %></label>
				</div>
				<div class="f-input">
					<span><strong>*</strong>商品单价:</span>
					<input type="text" class="field" disabled="disabled" 
					 value="<%=price%>" id="money" name="" />
				</div>
				<div class="f-input">
					<span><strong>*</strong>退款数量</span>
					<input type="text" class="field" id="returnteamno" value="" name="returnteamno" onblur="totalmaney(<%=order_id %>)" />
				</div>
				<div class="f-input">
					<span><strong>*</strong>退款总价</span>
					<input type="text" id="totalmoney" class="field" disabled="disabled" 
					 value="" />
				</div>
				<div class="f-input">
					<span><strong>*</strong>退货原因</span>
					<textarea rows="4" cols="60" id="reason" name="reason" ></textarea>
				</div>
				

				<div class="f-input">
					<center>
						<input type="button" class="gdbtn" onclick="return chance()" value="确认" />
					</center>
					</div>
				</div>
			</div>
			
			<div id="bottom">
				<div class="bottom_text">
					<!--footer begin-->
					<jsp:include page="/templets/html/teambuy/footer.jsp"></jsp:include>

					<!--footer over-->
				</div>
				</div>
			</div>
			<input type="hidden" id="team_tile" name="goods_name" value="" />
			<input type="hidden" id="user_id" name="user_id" value="<%=user_id %>" />
			<input type="hidden" id="team" name="goods_id" value="<%=info %>" />
			<input type="hidden" id="price" name="money" value="" />
			<input type="hidden" id="totalprice" name="totalmoney" value="" />
			<input type="hidden" name="bpm_id" value="7428" />
			<input type="hidden" name="cust_id" value="<%=cust_id%>" />
			<input type="hidden" name="order_no" value="<%=order_id %>" />
			<input type="hidden" name="returnstate" value="<%=returnstate %>" >
  </form>
  </body>
</html>
